package com.nodecollege.cloud.controller;

import com.nodecollege.cloud.common.annotation.UserLoginAnnotation;
import com.nodecollege.cloud.common.model.LoginUser;
import com.nodecollege.cloud.common.model.NCResult;
import com.nodecollege.cloud.common.model.po.UpmsMember;
import com.nodecollege.cloud.common.utils.ThreadUserUtils;
import com.nodecollege.cloud.service.MemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 成员中心
 *
 * @author LC
 * @date 2020/1/19 13:41
 */
@RestController
@UserLoginAnnotation
@RequestMapping("/memberCenter")
public class MemberCenterController {

    @Autowired
    private MemberService memberService;

    /**
     * 更新成员默认设置信息
     *
     * @param member
     * @return
     */
    @PostMapping("/updateMemberDefaultInfo")
    public NCResult updateMemberDefaultInfo(@RequestBody UpmsMember member) {
        LoginUser loginUser = ThreadUserUtils.getLoginUser();
        member.setTenantId(loginUser.getTenantId());
        memberService.updateMemberDefaultInfo(member, loginUser);
        return NCResult.ok();
    }
}
